Help for functions and procedures in disprecs.e

 

 

  disprecs.e is a collection of procedures and functions to display strings or sequences.

  Strings and sequences can also be extracted and/or displayed.

 

 

procedures and functions in disprecs.e

 

Display

 

DisplayText

 

ExtractText

 

DropDuplicates

 

 

Appendix:  Combining functions and procedures from other libraries to create a

             file browser.

 

 

 

                                       Display

 

 Syntax:      include disprecs.e

              Display(s)

 

       where: s is a sequence or string

 

 

 Description: Displays a string or sequence in a format that allows for up, down,

              left, and right scrolling.  Text can be scrolled a page at a time.

  Scrolling also occurs based on location of the cursor if it is within

  the displayed text area.

 

 

 Example:

              sequence textfile, text

              object line

              integer fn, e1

 

              textfile = “c:\euphoria\demo\queens.ex”

              fn       = open(textfile, “r”)

 

              if fn = -1 then

                puts(1, “file not found”)

                abort(1)

              end if

 

              while 1 do

                line = gets(fn)

    if integer(line) then

      exit

    end if

    e1 = length(line)

    if line[e1] = ‘\n’ then

      line = line[1..e1–1]

    end if

    text = append(text, line)

              end while

 

              close(fn)

 

              Display(text)

 

 

Comments:  A screen print file can be created by pressing F12.  The print file

  can be changed by changing the constant Default_Screenprint_File,

  at the beginning of the program.

 

 

                                   DisplayText

 

 Syntax:      include disprecs.e

              DisplayText (s1, s2)

 

       where: s1 is a string to search for in sequence s2

 

 

 Description: Display lines in sequence s2, that match search string s1

 

 Example:

              sequence QueensProgram

              DisplayText(“then”, QueensProgram)

 

 

See also:        ExtractText

 

 

                                   ExtractText

 

 

Syntax:       include disprecs.e

              s3 = ExtractText(s1, s2)

 

              where: s1 is a string to search for in sequence s2, and

                     s3 is the sequence returned with lines that matched.

 

 Description: Extract lines in sequence s2, that match search string s1

 

 

 Example:

              sequence QueensProgram, lines_with_then

 

              lines_with_then = ExtractText(“then”, QueensProgram)

 

 See also:        DisplayText

 

                                   DropDuplicates

 

 

 Syntax:      include disprecs.e

              s2 = DropDuplicates(s1)

 

             s2 is a sequence which has the duplicate consecutive lines

             dropped from sequence s1

 

 Description: From sequence s1, drop the lines that are

             duplicates of the previous line.

 

 

Example:

 

              sequence duplicates, non_duplicates

              non_duplicates = DropDuplicates(duplicates)

 

 

 

 

      Appendix

 

 Creating a file browser by combining other libraries:

 

  include get.e

  include graphics.e

  include keys.e

  include fileio.e

  include disprecs.e

 

  constant Text_File_In = “c:\\euphoria\\demo\\queens.ex”,

           Binary_File_In = “C:\\euphoria\\bin\\ex.exe”,

           LRECL = 80

 

  sequence text_array, binary_array

  text_array = LoadTextFile(Text_File_In)

  Display(text_array)

 

  binary_array = LoadBinaryFile(BinFile, LRECL)

  Display(binary_array)